<div class="content-section introduction">
    <div>
        <span class="feature-title">Menu</span>
        <span>Menu is a navigation/command component that supports dynamic and static positioning.</span>
    </div>
</div>

<div class="content-section implementation">
    <h3 class="first">Basic</h3>
    <p-menu [model]="items"></p-menu>

    <h3>Popup</h3>
    <p-menu #menu popup="popup" [model]="items"></p-menu>
    <button type="button" pButton icon="fa fa-list" label="Show" (click)="menu.toggle($event)"></button>
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;MenuModule,MenuItem&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>MenuModel API</h3>
            <p>Menu uses the common menumodel api to define its items, visit <a [routerLink]="['/menumodel']">MenuModel API</a> for details.</p>

            <h3>Getting Started</h3>
            <p>Menu requires a collection of menuitems as its model.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-menu [model]="items"&gt;&lt;/p-menu&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MenuDemo &#123;
    
    items: MenuItem[];

    ngOnInit() &#123;
        this.items = [
                    &#123;label: 'New', icon: 'fa-plus'&#125;,
                    &#123;label: 'Open', icon: 'fa-download'&#125;,
                    &#123;label: 'Undo', icon: 'fa-refresh'&#125;
                ];
    &#125;
&#125;
</code>
</pre>

            <h3>SubMenus</h3>
            <p>Menu supports 1 level of nesting via subitems of an item.</p>
<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MenuDemo &#123;
    
    items: MenuItem[];

    ngOnInit() &#123;
        this.items = [&#123;
            label: 'File',
            items: [
                &#123;label: 'New', icon: 'fa-plus'&#125;,
                &#123;label: 'Open', icon: 'fa-download'&#125;
            ]
        &#125;,
        &#123;
            label: 'Edit',
            items: [
                &#123;label: 'Undo', icon: 'fa-refresh'&#125;,
                &#123;label: 'Redo', icon: 'fa-repeat'&#125;
            ]
        &#125;];
    &#125;
&#125;
</code>
</pre>

            <h3>Popup Mode</h3>
            <p>Menu is inline by default, popup mode is also supported by enabling popup property and calling toggle method by passing the event 
                    from the anchor element.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-menu #menu popup="popup" [model]="items"&gt;&lt;/p-menu&gt;
&lt;button type="button" pButton icon="fa fa-list" label="Show" (click)="menu.toggle($event)"&gt;&lt;/button&gt;
</code>
</pre>
       
            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Type</th>
                        <th>Default</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>model</td>
                            <td>array</td>
                            <td>null</td>
                            <td>An array of menuitems.</td>
                        </tr>
                        <tr>
                            <td>popup</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Defines if menu would displayed as a popup.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>appendTo</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <h3>Methods</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>toggle</td>
                            <td>event: browser event</td>
                            <td>Toggles the visibility of the popup menu.</td>
                        </tr>
                        <tr>
                            <td>show</td>
                            <td>event: browser event</td>
                            <td>Displays the popup menu.</td>
                        </tr>
                        <tr>
                            <td>hide</td>
                            <td>-</td>
                            <td>Hides the popup menu.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Styling</h3>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>ui-menu</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>ui-menu-list</td>
                            <td>List element.</td>
                        </tr>
                        <tr>
                            <td>ui-menuitem</td>
                            <td>Menuitem element.</td>
                        </tr>
                        <tr>
                            <td>ui-menuitem-text</td>
                            <td>Label of a menuitem.</td>
                        </tr>
                        <tr>
                            <td>ui-menuitem-icon</td>
                            <td>Icon of a menuitem.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Dependencies</h3>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/menu" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;h3 class="first"&gt;Basic&lt;/h3&gt;
&lt;p-menu [model]="items"&gt;&lt;/p-menu&gt;

&lt;h3&gt;Popup&lt;/h3&gt;
&lt;p-menu #menu popup="popup" [model]="items"&gt;&lt;/p-menu&gt;
&lt;button type="button" pButton icon="fa fa-list" label="Show" (click)="menu.toggle($event)"&gt;&lt;/button&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MenuDemo &#123;
    
    items: MenuItem[];

    ngOnInit() &#123;
        this.items = [&#123;
            label: 'File',
            items: [
                &#123;label: 'New', icon: 'fa-plus'&#125;,
                &#123;label: 'Open', icon: 'fa-download'&#125;
            ]
        &#125;,
        &#123;
            label: 'Edit',
            items: [
                &#123;label: 'Undo', icon: 'fa-refresh'&#125;,
                &#123;label: 'Redo', icon: 'fa-repeat'&#125;
            ]
        &#125;];
    &#125;
&#125;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>